#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+10;
vector<int> bian[N];
int siz[N];
int C[N];
void dfs(int x,int fa){
    siz[x] = 1;
    for(int v : bian[x]){
        if(v == fa){
            continue;
        }
        dfs(v,x);
        siz[x] += siz[v];
    }
    C[siz[x]]++;
}
int n;
bool chk(int v){
    int rc = 0;
    for(int i = v;i <= n;i += v){
        rc += C[i]*v;
    }
    return rc == n;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i = 1;i<n;i++){
        int u,v;
        cin>>u>>v;
        bian[u].push_back(v);
        bian[v].push_back(u);
    }
    dfs(1,0);
    int cnt = 0;
    for(int i = 1;i * i <= n;i++){
        if(n % i == 0){
            cnt += chk(i);
            if(n / i != i){
                cnt += chk(n/i);
            }
        }
    }
    cout<<cnt<<'\n';
}